#pragma once
#include "util.h"
#include <IceUtil\Time.h>

namespace Xts
{
	namespace Util
	{
		class XTimezoneDateTime
		{
		public:
			XTimezoneDateTime(const Ice::Short& year, const Ice::Short& month, const Ice::Short& day, 
				const Ice::Short& hour, const Ice::Short& minute, const Ice::Short& second,
				const Ice::Short& milisec, const Ice::Short& microsec, const Ice::Long& timezoneInterval);
			//timezoneInterval = UtcTime - LocalTime in seconds
			XTimezoneDateTime(const Ice::Short& year, const Ice::Short& month, const Ice::Short& day,
				const Ice::Short& hour, const Ice::Short& minute, const Ice::Short& second,
				const Ice::Short& milisec, const Ice::Short& microsec, XTimeZone timeZone);

			~XTimezoneDateTime(){}

			static Ice::Long GetTimeZoneInterval(XTimeZone timeZone);

			const Ice::Short& Year()const{ return x_year; }
			const Ice::Short& Month()const{ return x_month; }
			const Ice::Short& Day()const{ return x_day; }
			const Ice::Short& Hour()const{ return x_hour; }
			const Ice::Short& Minute()const{ return x_minute; }
			const Ice::Short& Second()const{ return x_second; }
			const Ice::Short& Milisec()const{ return x_milisec; }
			const Ice::Short& Microsec()const{ return x_microsec; }
			const Ice::Long& TimezoneInterval()const{ return x_timezoneInterval; }			

		protected:
			Ice::Short x_year;
			Ice::Short x_month;
			Ice::Short x_day;
			Ice::Short x_hour;
			Ice::Short x_minute;
			Ice::Short x_second;
			Ice::Short x_milisec;
			Ice::Short x_microsec;
			Ice::Long x_timezoneInterval;			
		};

		class XTimeAdapter
		{
		public:
			XTimeAdapter(const XTime& tomTime);
			XTimeAdapter(const IceUtil::Time& icTime);
			XTimeAdapter(const Ice::Short& year, const Ice::Short& month, const Ice::Short& day,
				const Ice::Short& hour = 0, const Ice::Short& minute = 0, const Ice::Short& second = 0, 
				const Ice::Short& milisec = 0, const Ice::Short& microsec = 0);
			XTimeAdapter(const Ice::Short& year = 1970, const Ice::Short& month = 1, const Ice::Short& day = 1,
				const Ice::Short& hour = 0, const Ice::Short& minute = 0, const Ice::Short& second = 0, 
				const Ice::Short& milisec = 0, const Ice::Short& microsec = 0,
				const Ice::Long& timezoneInterval = 0);
			XTimeAdapter(const XTimezoneDateTime& xdtTime);
			~XTimeAdapter();

			XTime ToXTime(){ return x_tomTime; }
			IceUtil::Time ToIceTime(){ return x_icTime; }
			XTimezoneDateTime ToXTimezoneDateTime(const Ice::Long& timezoneInterval);
			XTimezoneDateTime ToXTimezoneDateTime(XTimeZone timezone);
			static bool GetLocalTimezoneInterval(Ice::Long& localTimezoneInterval);

		protected:
			void IceTime2XTime();
			void XTime2IceTime();
			

		protected:
			IceUtil::Time x_icTime;
			XTime x_tomTime;

		private:
			static Ice::Long x_localTimezoneInterval;
			static bool x_isLocalTimezoneSet;
		};

		
	}
}


